﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DoAnOOP.BussinessLayer;

namespace DoAnOOP
{
    public partial class frmLyLichGV : Office2007Form
    {
        int countKhoa = 0;
        int countGioi = 0;
        int countNgaySinh = 0;
        int countNgayVaoLam = 0;
        public frmLyLichGV()
        {
            InitializeComponent();
        }

        private void frmLyLichGV_Load(object sender, EventArgs e)
        {
            FillInfo();
        }
        private void FillInfo()
        {
            clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
            txtMaGV.Text = clsMyBusLyLichGV.GetMaGV();
            txtHo.Text = clsMyBusLyLichGV.GetHo();
            txtTen.Text = clsMyBusLyLichGV.GetTen();
            txtHocVi.Text = clsMyBusLyLichGV.GetHocVi();
            txtHocHam.Text = clsMyBusLyLichGV.GetHocHam();
            radiNam.Checked = clsMyBusLyLichGV.GetGioiTinhNam();
            radiNu.Checked = !clsMyBusLyLichGV.GetGioiTinhNam();
            txtNoiSinh.Text = clsMyBusLyLichGV.GetNoiSinh();
            dateNgaySinh.Value = clsMyBusLyLichGV.GetNgaySinh();
            dateNgayLam.Value = clsMyBusLyLichGV.GetNgayLam();
            // Điền vào comboKhoa
            List<string> ds = new List<string>();
            ds = clsMyBusLyLichGV.GetDSKhoa();
            for (int i = 0; i < ds.Count(); i++)
                comboKhoa.Items.Add(ds[i]);
            comboKhoa.Text = clsMyBusLyLichGV.GetKhoa();
        }

        private void txtMaGV_MouseLeave(object sender, EventArgs e)
        {
            this.Refresh();
        }


        private void txtHo_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyBusLyLichGV.UpdateHo(txtHo.Text);
                txtHo.Refresh();
            }
        }
        private void txtTen_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyBusLyLichGV.UpdateTen(txtTen.Text);
                txtHo.Refresh();
            }
        }


        private void txtNoiSinh_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyBusLyLichGV.UpdateNoiSinh(txtNoiSinh.Text);
                txtNoiSinh.Refresh();
            }
        }

        private void txtHocVi_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyBusLyLichGV.UpdateHocVi(txtHocVi.Text);
                txtHocVi.Refresh();
            }
        }

        private void txtHocHam_MyEvent(object sender, MyEventArgs e)
        {
            clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
            DialogResult kq = MessageBox.Show("Bạn có muốn thay đổi?", "Thông báo", MessageBoxButtons.OKCancel);
            if (kq == System.Windows.Forms.DialogResult.OK)
            {
                clsMyBusLyLichGV.UpdateHocHam(txtHocHam.Text);
                txtHocHam.Refresh();
            }
        }

        private void comboKhoa_SelectedValueChanged(object sender, EventArgs e)
        {
            countKhoa++;
            if (countKhoa > 1)
            {
                clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
                clsMyBusLyLichGV.UpdateKhoa(comboKhoa.Text);
            }
        }



        private void radiNam_CheckedChanged(object sender, EventArgs e)
        {
            countGioi++;
            if (countGioi > 1)
            {
                if (radiNam.Checked == true)
                {
                    clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
                    clsMyBusLyLichGV.UpdateGioi("Nam");

                }
            }
        }

        private void radiNu_CheckedChanged(object sender, EventArgs e)
        {
            countGioi++;
            if (countGioi > 1)
            {
                if (radiNu.Checked == true)
                {
                    clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
                    clsMyBusLyLichGV.UpdateGioi("Nu");
                }
            }
        }

        private void dateNgaySinh_ValueChanged(object sender, EventArgs e)
        {
            countNgaySinh++;
            if (countNgaySinh > 1)
            {
                clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
                clsMyBusLyLichGV.UpdateNgaySinh(dateNgaySinh.Value.ToString("s")); // s quy định dạng yyyy-MM-dd hh:mm:ss
            }
        }

        private void dateNgayLam_ValueChanged(object sender, EventArgs e)
        {
            countNgayVaoLam++;
            if (countNgayVaoLam > 1)
            {
                clsBusLyLichGV clsMyBusLyLichGV = new clsBusLyLichGV();
                clsMyBusLyLichGV.UpdateNgayVaoLam(dateNgayLam.Value.ToString("s")); // s quy định dạng yyyy-MM-dd hh:mm:ss

            }
        }


        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {

        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void label6_Click(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void label8_Click(object sender, EventArgs e)
        {

        }

        private void label9_Click(object sender, EventArgs e)
        {

        }

        private void label10_Click(object sender, EventArgs e)
        {

        }

        private void comboKhoa_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void txtMaGV_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtHocHam_Load(object sender, EventArgs e)
        {

        }

        private void txtTen_Load(object sender, EventArgs e)
        {

        }

        private void txtNoiSinh_Load(object sender, EventArgs e)
        {

        }

        private void txtHocVi_Load(object sender, EventArgs e)
        {

        }

        private void txtHo_Load(object sender, EventArgs e)
        {

        }


    }
}
